package core;

import java.util.ArrayList;
import java.util.List;

import card.BuildingCard;
import card.Card;
import card.CreatureCard;
import card.buildings.Academy;
import card.buildings.Blacksmith;
import card.buildings.Castle;
import card.buildings.Labroratory;
import card.buildings.Magicstore;
import card.buildings.MarketPlace;
import card.buildings.Tower;
import card.buildings.University;
import card.buildings.Wall;
import card.buildings.WatchTower;
import card.buildings.Windmill;
import card.buildings.Workshop;
import card.creatures.Asrai;
import card.creatures.Barbarian;
import card.creatures.Diser;
import card.creatures.DwarvenProspector;
import card.creatures.DwarvenWarrior;
import card.creatures.ElvenRanger;
import card.creatures.Fairy;
import card.creatures.Gast;
import card.creatures.Gnome;
import card.creatures.Goblin;
import card.creatures.GoblinThief;
import card.creatures.GreenDragon;
import card.creatures.Halfling;
import card.creatures.Harpy;
import card.creatures.Hrimturse;
import card.creatures.Imp;
import card.creatures.Knight;
import card.creatures.MagmaDragon;
import card.creatures.Mara;
import card.creatures.OrcMarauder;
import card.creatures.OrcWarrior;
import card.creatures.Peasant;
import card.creatures.Skeleton;
import card.creatures.SwampTroll;
import card.creatures.Wolf;

/**
 * 
 * @author Oscar
 *A class for generating a random deck, using all the cards we've created so far.
 *
 */
public class DeckGenerator {
	
	private static DeckGenerator me;
	
	public static DeckGenerator getInstance(){
		if(me == null)
			me = new DeckGenerator();
		return me;
	}
	
	/**
	 * GenerateDeck uses other methods for creating smaller random decks for each specific card type. The method
	 * then adds all the different "mini-decks" into the main deck and shuffles it.
	 */
	public List<Card> generateDeck(){
		List<Card> deck = new ArrayList<Card>();
		List<CreatureCard> creatureCards = generateCreatureCards();
		List<BuildingCard> buildingCards = generateBuildingCards();
		
		deck.addAll(creatureCards);
		deck.addAll(buildingCards);
		RandomGenerator.shuffle(deck);
		
		return deck;
	}
	
	/**
	 * Generates a deck of 10 random CreatureCards.
	 */
	private List<CreatureCard> generateCreatureCards(){
		List<CreatureCard> creatureCards = new ArrayList<CreatureCard>();
		
		creatureCards.add(new Barbarian());
		creatureCards.add(new DwarvenProspector());
		creatureCards.add(new DwarvenWarrior());
		creatureCards.add(new ElvenRanger());
		creatureCards.add(new Fairy());
		creatureCards.add(new Gast());
		creatureCards.add(new Gnome());
		creatureCards.add(new Goblin());
		creatureCards.add(new GoblinThief());
		creatureCards.add(new GreenDragon());
		creatureCards.add(new Halfling());
		creatureCards.add(new Harpy());
		creatureCards.add(new Knight());
		creatureCards.add(new MagmaDragon());
		creatureCards.add(new OrcMarauder());
		creatureCards.add(new OrcWarrior());
		creatureCards.add(new Peasant());
		creatureCards.add(new Skeleton());
		creatureCards.add(new SwampTroll());
		creatureCards.add(new Wolf());
		creatureCards.add(new Hrimturse());
		creatureCards.add(new Mara());
		creatureCards.add(new Asrai());
		creatureCards.add(new Imp());
		creatureCards.add(new Diser());
		
		RandomGenerator.shuffle(creatureCards);
		
		/*for(int i=19; i>9; i--)
			creatureCards.remove(i);*/
		
		return creatureCards;
	}
	
	/**
	 * Generates a deck of 10 random CreatureCards.
	 */
	private List<BuildingCard> generateBuildingCards(){
		List<BuildingCard> buildingCards = new ArrayList<BuildingCard>();
		
		buildingCards.add(new Windmill());
		buildingCards.add(new Academy());
		buildingCards.add(new Blacksmith());
		buildingCards.add(new Castle());
		buildingCards.add(new Labroratory());
		buildingCards.add(new Magicstore());
		buildingCards.add(new MarketPlace());
		buildingCards.add(new Tower());
		buildingCards.add(new University());
		buildingCards.add(new WatchTower());
		buildingCards.add(new Workshop());
		buildingCards.add(new Wall());
		
		RandomGenerator.shuffle(buildingCards);
		
		/*for(int i=10; i>5; i--)
			buildingCards.remove(i);*/
		
		return buildingCards;
	}
}
